#include <vector>

class NumArray {
public:
    std::vector<int> sum;
    NumArray(std::vector<int>& nums) {
        int n = nums.size();
        sum.push_back(nums[0]);
        for (int i = 1; i <= n; i++)
        {
            sum.push_back(sum[i-1]+nums[i-1]);
        }
    }
    
    int sumRange(int left, int right) {
        return sum[right+1]-sum[left];
    }
};

